<?php
/**
 * Archivo de configuración
 */

session_start();

/** define the site path constant **/
$site_path = realpath(dirname(__FILE__)).'/';

require_once $site_path.'define.inc.php';

/** include path libraries **/
set_include_path(
	get_include_path().
	PATH_SEPARATOR.$site_path.'phpinc/'.
	PATH_SEPARATOR.$site_path.'src/'.
	PATH_SEPARATOR.$site_path.'src/'.'controllers/'.
	PATH_SEPARATOR.$site_path.'src/'.'views/'.
	PATH_SEPARATOR.$site_path.'src/'.'models/'.
	PATH_SEPARATOR.$site_path.'src/'.'models/base/'.
	PATH_SEPARATOR.$site_path.'admin/'.
	PATH_SEPARATOR.$site_path.'admin/modules/'
);

/*+ doctrine configuration **/
require_once 'phpinc/doctrine/Doctrine.php';

spl_autoload_register(array('Doctrine', 'autoload'));
Doctrine_Manager::getInstance();
$con = Doctrine_Manager::connection(DB_TYPE_CONNECTION.'://'.DB_USER.':'.DB_PASSWORD.'@'.DB_SERVER.'/'.DB_NAME);
if(is_dir('src/models'))
    $dirModel = 'src/models';
elseif(is_dir('../src/models'))
    $dirModel = '../src/models';
$con->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
$con->setCharset('utf8');
Doctrine_Core::loadModels(array($dirModel.'/base',$dirModel));

$tables = $con->import->listTables('MFConfiguration');
if(!is_int(array_search('mf_configuration',$tables)))
{
    define('__SRC_PATH','src/');
    define('DEBUG',true);
} else
    require_once $site_path.'settings.inc.php';

/** error reporting on **/
if(DEBUG)
	error_reporting(E_ERROR | E_WARNING | E_PARSE);
else
	error_reporting(0);

/** include the web application class **/
require_once 'web_application.class.php';

/** include the controller class **/
require_once 'controller_base.class.php';

/** include the view class **/
require_once 'view_base.class.php';

$web = new webApplication;

?>